<template>
  <div class="renderer-generator">
    <div class="left">
      <RevForm :fields="form" :config="{ labelPosition: 'top' }" />
    </div>
    <div class="btn">
      <el-button type="primary" size="default" @click="doGen">生成</el-button>
    </div>
    <div class="right">
      <RevForm :fields="result" :config="{ labelPosition: 'top' }" />
    </div>
  </div>
</template>

<script>
import { doGenerator } from '@/api/basic'
export default {
  name: 'RevGenerator',
  props: {
    config: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      result: []
    }
  },
  computed: {
    form() {
      return this.config?.input?.form
    }
  },
  methods: {
    async doGen() {
      const { form } = await doGenerator({
        key: this.config?.key,
        form: this.form
      })
      this.result = form
    }
  }
}
</script>

<style lang="less" scoped>
.renderer-generator {
  padding: 10px;
  display: flex;
  flex-direction: column;

  .left {
    flex: 1;
  }
  .right {
    flex: 1;
    overflow: auto;
  }
  .btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
  }
}
</style>
